package com.collabarative1.connectionUtils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionFactory 
	{

		static String driverClassName="oracle.jdbc.driver.OracleDriver";
		static String url="jdbc:oracle:thin:@localhost:1521:xe";
		static String username="system";
		static String password="system";
                Connection con=null;
		public static Connection getConnection() 
		{

			//Class c=Class.forName(driverClassName);
//			Driver d=(Driver)c.newInstance();
//			// Obtain a connection
//			Properties p=new  Properties();
//			p.put("username",username);
//			p.put("password", password);
//			Connection con=d.connect(url,p);
			try {
				Class.forName(driverClassName);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			Connection con = null;
			try {
				con = DriverManager.getConnection(url,username,password);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			
			return con;
		}
		public static void close(Connection con) {
			try {
				con.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	
	

